import { IPSAppUILogicRefView } from './ipsapp-uilogic-ref-view';
import { IPSAppUIOpenDataLogic } from './ipsapp-uiopen-data-logic';
import { PSAppUILogicImpl } from './psapp-uilogic-impl';

export class BuiltinPSAppUIOpenDataLogicImpl extends PSAppUILogicImpl implements IPSAppUIOpenDataLogic {
  protected opendatapsappview: IPSAppUILogicRefView | null = null;

  getOpenDataPSAppView(): IPSAppUILogicRefView | null {
    if (this.opendatapsappview != null) return this.opendatapsappview;
    const value = this.M.getOpenDataPSAppView;
    if (value == null) {
      return null;
    }
    this.opendatapsappview = this.getPSModel4('app.logic.IPSAppUILogicRefView', value, 'getOpenDataPSAppView') as IPSAppUILogicRefView;
    return this.opendatapsappview;
  }

  get openDataPSAppView(): IPSAppUILogicRefView | null {
    return this.getOpenDataPSAppView();
  }

  getOpenDataPSAppViewMust(): IPSAppUILogicRefView {
    const value = this.getOpenDataPSAppView();
    if (value == null) {
      throw new Error('未指定默认打开数据视图');
    }
    return value;
  }

  protected opendatapsappviews: IPSAppUILogicRefView[] | null = null;

  getOpenDataPSAppViews(): IPSAppUILogicRefView[] | null {
    if (this.opendatapsappviews == null) {
      this.opendatapsappviews = this.fillChildListModel(this.M.getOpenDataPSAppViews, 'app.logic.IPSAppUILogicRefView') as IPSAppUILogicRefView[];
    }
    return this.opendatapsappviews;
  }

  get openDataPSAppViews(): IPSAppUILogicRefView[] | null {
    return this.getOpenDataPSAppViews();
  }

  findOpenDataPSAppUILogicRefView(objKey: any): IPSAppUILogicRefView | null {
    return this.getPSModel5('app.logic.IPSAppUILogicRefView', this.getOpenDataPSAppViews(), objKey) as IPSAppUILogicRefView;
  }

  get viewLogicType(): string {
    return this.M.viewLogicType;
  }

  get editMode(): boolean {
    return this.M.editMode;
  }

  get cls(): string {
    return 'BuiltinPSAppUIOpenDataLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelObject' || cls == 'IPSObject' || cls == 'app.logic.IPSAppUILogic' || cls == 'app.logic.IPSAppUIOpenDataLogic' || cls == 'res.IPSSysViewLogic' || cls == 'view.IPSViewLogic')
      return true;
    return super.instanceof(cls);
  }
}
